package com.test.netty.factory;

import com.test.netty.handler.MyInvocationHandler;

import java.lang.reflect.Proxy;

public class ProxyFactory {

    public static <T> T getProxy(final Class<?> interfaceClass, Class<?> implClass) {

        MyInvocationHandler invocationHandler = new MyInvocationHandler(interfaceClass, implClass);

//        return (T) Proxy.newProxyInstance(interfaceClass.getClassLoader(), new Class[]{interfaceClass}, invocationHandler);
        return (T) Proxy.newProxyInstance(implClass.getClassLoader(), implClass.getInterfaces(), invocationHandler);
    }
}
